1. Field of the Invention
The present invention relates to an H.264 coder and decoder, and more particularly to a deblocking filtering method and a deblocking filter for performing deblocking filtering when decoding the original image data.
2. Description of the Related Art
Generally, since a deblocking filter compresses and encodes image data by the block in a video coding standard such as an H.264 scheme, and then decodes the coded data, blocking artifacts may occur in a restored image. Such blocking artifacts are mainly caused by two factors. In relation to the first factor, block-based encoding performs Discrete Cosine Transform (DCT) and quantization on a block of constant size causes data loss. This is because the transform and the quantization are independently performed without considering correlation among adjacent blocks or pixels. In relation to the second factor, in a process of estimating a motion vector by the block and compensating for images, pixels belonging to one block have the same motion vector.
In such a case, a deblocking filter reduces the boundary error of a block occurring in such block-based coding, thereby improving the quality of the finally restored image.
FIG. 1 is a flow diagram illustrating a deblocking filtering process performed by a conventional deblocking filter.
Referring to FIG. 1, if image data is input, the conventional deblocking filter divides the input image data into macro blocks in step 100, wherein each of the macro blocks includes a predetermined number of pixel blocks. Generally, such a macro block includes 16 (4×4) pixel blocks.
In step 102, the deblocking filter selects one of the divided macro blocks according to a preset order. In step 104, the deblocking filter selects two boundary blocks based on one of horizontal boundaries within the macro block, i.e. two pixel blocks horizontally connected adjacent to the selected horizontal boundary according to a preset order. Herein, the boundary denotes a boundary (i.e. an edge) of a vertical or horizontal direction between two pixel blocks adjacent in a vertical or horizontal direction. The boundary block denotes a pixel block adjacent to the currently selected boundary selected in order to compute the Boundary Strength (BS) value of the currently selected boundary.
TABLE 112345678910111213141516
When macro blocks are as illustrated in Table 1, if boundary blocks are pixel blocks 5 and 6, a vertical boundary corresponds to a boundary between the pixel blocks 5 and 6. Similarly, if boundary blocks are pixel blocks 5 and 9, a horizontal boundary corresponds to a boundary between the pixel blocks 5 and 9.
In step 106, the deblocking filter computes a BS value based on a horizontal direction boundary of the selected boundary blocks. The BS value is for setting filtering strength in the filtering process by the deblocking filter. In step 106, the deblocking filter computes a BS value (i.e. a horizontal direction BS value) based on the horizontal direction boundary according to (1) whether the currently selected boundary blocks have been intra-coded, or (2) whether the selected boundary blocks are determined as different blocks based on intra-coding results when they are not intra-coded blocks, or (3) whether the boundary blocks have the same reference picture, or (4) whether a difference in motion vector values between the boundary blocks is more than a predetermined value, or (5) whether the boundary blocks correspond to the block boundary of the macro block when they are the intra-coded blocks, etc.
FIG. 2 is a flow diagram illustrating in more detail a process of computing a horizontal direction BS value for the currently selected boundary blocks in step 106.
Referring to FIG. 2, if the boundary blocks based on the horizontal direction boundary are selected, the deblocking filter determines if the currently selected boundary blocks are the intra-coded blocks in step 200. As a result of the determination in step 200, if the currently selected boundary blocks are the intra-coded blocks, the deblocking filter determines if the currently selected horizontal direction boundary corresponds to the boundary surface (i.e. edge) of the currently selected macro block in step 202. If the currently selected horizontal direction boundary corresponds to the boundary surface, the deblocking filter sets the BS value of the currently selected horizontal direction boundary to a value, e.g., 4, denoting the strongest deblocking filtering level in step 204. However, if the currently selected horizontal direction boundary does not correspond to the boundary surface, the deblocking filter sets the BS value of the currently selected horizontal direction boundary to a value, e.g., 3, less than the strongest deblocking filtering level, in step 206.
As a result of the determination in step 200, if the currently selected boundary blocks are not the intra-coded blocks, the deblocking filter confirms and compares Coded Block Pattern (CBP) values of the currently selected boundary blocks in step 208. If all the CBP values are 0, it may be determined that the blocks have no difference. However, if at least one of the CBP values is 1, it may be determined that the blocks are different.
In step 210, the deblocking filter determines if there is a difference between the currently selected boundary blocks as a result of the comparison of the CBP values. If there is a difference between the currently selected boundary blocks, the deblocking filter sets the BS value of the currently selected horizontal direction boundary to a value, e.g., 2, in step 212.
However, if there is no difference between the currently selected boundary blocks, the deblocking filter determines if the currently selected boundary blocks have the same reference picture, or if a difference in motion vector values for vertical and horizontal directions in each boundary block is more than a predetermined value in step 214. If the currently selected boundary blocks do not have the same reference picture, or if the difference in the motion vector values is more than the predetermined value, the deblocking filter sets the BS value of the currently selected horizontal direction boundary to a value, e.g., 1. in step 216. However, if the currently selected boundary blocks have the same reference picture, or if the difference in the motion vector values is less than the predetermined value, the deblocking filter sets the BS value of the currently selected horizontal direction boundary to a value, e.g., 0, thereby skipping deblocking filtering in step 218. Then, step 108 in FIG. 1 is performed.
In this way, if the BS value is computed, this becomes a BS value based on the specific direction of a specific pixel. For example, as illustrated in Table 1, if the BS value of the vertical boundary is computed, this value typically becomes the BS value of pixel 6 which is a pixel block located in the right side of the vertical boundary. If the BS value of the horizontal boundary is computed, this value typically becomes the BS value of pixel 5 which is a pixel block located in the upper side of the horizontal boundary.
Further, if the computation of the horizontal direction BS value for the currently selected boundary blocks in step 106 is completed, the deblocking filter determines if the horizontal direction BS values for all horizontal boundaries of the currently selected macro block have been computed in step 108 (returning to FIG. 1). If the horizontal direction BS values have not been computed, the deblocking filter selects other boundary blocks in step 104 and repeats step 106. However, if the computation of the BS values for all horizontal boundaries of the currently selected macro block is completed, the deblocking filter determines if steps 100, 102, 104, 106 and 108 have been performed for all macro blocks divided from the input image data, in step 110. As a result of the determination in step 110, if the horizontal direction BS values for each boundary block of all macro blocks have been completed, the deblocking filter performs a deblocking filtering process based on a horizontal direction in step 112.
If the deblocking process is completed in step 112, the deblocking filter selects one of the macro blocks divided from the image data in step 114. In step 116, the deblocking filter selects two boundary blocks based on one of the horizontal boundaries inside the currently selected macro block, i.e. two boundary blocks horizontally connected adjacent to the currently selected vertical boundary. In step 118, the deblocking filter computes the BS value in a vertical direction in a way similar to that of step 106. The difference between step 106 and step 118 is as follows: in step 106, the BS value is computed according to the correlation between two vertically connected boundary blocks, however, in step 118, the BS value is computed according to the correlation between two horizontally connected boundary blocks.
In steps 120 and 122, the deblocking filter computes vertical direction BS values for vertical boundaries of all macro blocks. If these vertical direction BS values are computed in step 122, the deblocking filter performs vertical direction filtering of each boundary block according to the computed BS values in step 124. In this way, the deblocking filtering in horizontal and vertical directions for all macro blocks of the input image data is completed.
As describe above, the conventional deblocking filter must compute the BS values for all horizontal direction boundaries of the input image data, and then repeat the BS value computation process (step 118) for computing the vertical direction boundaries. Therefore, the filtering method of the deblocking filter requires a large computation amount, which results in an increase in the time required for filtering.